package demon;

import demon.IList;

import java.util.Arrays;

public class MyArraylist implements IList {

    public int[] elem;
    public int usedSize;//0
    //默认容量
    private static final int DEFAULT_SIZE = 10;

    public MyArraylist() {
       elem =new int [DEFAULT_SIZE];
    }

    @Override
    public void display() {

    }

    @Override
    public void add(int data) {
        if(isFull()) {
            //扩容
            this.elem = Arrays.copyOf(this.elem,2*this.elem.length);
        }
        this.elem[this.usedSize] = data;
        this.usedSize++;
    }

    @Override
    public boolean isFull() {
        return this.usedSize == this.elem.length;
    }

    @Override
    public void checkPosInAdd(int pos) {
        if(pos < 0 || pos > this.usedSize) {
            throw new MyArrayListIndexOutOfException("添加方法的pos不合理！");
        }

    }

    @Override
    public void add(int pos, int data) {

    }

    @Override
    public boolean contains(int toFind) {
        return false;
    }

    @Override
    public int indexOf(int toFind) {
        return 0;
    }

    @Override
    public int get(int pos) {
        return 0;
    }

    @Override
    public boolean isEmpty() {
        return false;
    }

    @Override
    public void set(int pos, int value) {

    }

    @Override
    public void remove(int key) {

    }

    @Override
    public int size() {
        return 0;
    }

    @Override
    public void clear() {

    }
}
